#ifndef SERVERMAIN_H_
#define SERVERMAIN_H_

#include "scatu/ServerDefs.h"

namespace scatu {

template<typename ServerType>
void RunServerL()
    {
    // naming the server thread after the server helps to debug panics
    User::LeaveIfError(RThread::RenameMe(KServerName()));
    //
    // create and install the active scheduler we need
    CActiveScheduler* s = new(ELeave) CActiveScheduler;
    CleanupStack::PushL(s);
    CActiveScheduler::Install(s);
    //
    // create the server (leave it on the cleanup stack)
    ServerType::NewLC();
    //
    // Initialisation complete, now signal the client
    RProcess::Rendezvous(KErrNone);
    //
    // Ready to run
    CActiveScheduler::Start();
    //
    // Cleanup the server and scheduler
    CleanupStack::PopAndDestroy(2, s);
    }

} // namespace scatu

#endif /* SERVERMAIN_H_ */
